package com.lagou.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.apache.commons.dbutils.QueryRunner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.*;

import javax.sql.DataSource;

/**
 * @Author wsl
 * @Date 2021/11/10 6:24
 * @Project_Name jdbc_spring
 */

@Configuration //核心配置类
@ComponentScan("com.lagou") //注解扫描
@Import(DataSourceConfig.class) //导入其他配置类
public class SpringConfig {

    @Bean("queryRunner") //注解：将返回值存储到spring容器中
    public QueryRunner getQueryRunner(@Autowired DataSource dataSource){//@Autowired 依赖注入

        QueryRunner queryRunner = new QueryRunner(dataSource);
        return queryRunner;
    }

}
